package com.atguigu.gulimail.search.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class ThreadTest {
    public static ExecutorService executorService = Executors.newFixedThreadPool(10);
//    private static  ThreadPoolExecutor executor = new ThreadPoolExecutor();

    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        System.out.println("main方法开始执行");
//        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
//            System.out.println("当前线程运行。。。。。");
//        }, executorService).whenComplete(((u,t) ->{
//            System.out.println("异步任务执行完成"+u);
//        }));
//        Void unused = completableFuture.get();//获取返回值的方法
//        System.out.println("main方法执行结束");
        CompletableFuture<Integer> fu1 = CompletableFuture.supplyAsync(() -> {
            System.out.println("当前线程运行。。。。。");
            return 1;
        });
        CompletableFuture<String> fu2 = CompletableFuture.supplyAsync(() -> {
            System.out.println("当前线程运行。。。。。");
            return "hello";
        });
        CompletableFuture<Void> of = CompletableFuture.allOf(fu1, fu2);
        of.get();
    }
//    public static void thread(String[] args) {
//        System.out.println("main....");
//        Runnable1 runnable1 = new Runnable1();
//        new Thread(runnable1).start();
//        executorService.execute(runnable1);
//
//    }
    public static class Runnable1 implements Runnable{

        @Override
        public void run() {
            System.out.println("当前线程运行。。。。。");
        }
    }
}
